home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Morphos / GCC / ppc-amigaos / include / net / if.h
C/C++ Source or Header  |  1997-12-28  |  6KB  |  172 lines

  1. #ifndef _NET_IF_H_
  2. #define    _NET_IF_H_
  3.  
  4. #ifndef _SYS_TYPES_H_
  5. #include <sys/types.h>
  6. #endif
  7.  
  8. #ifndef _SYS_SOCKET_H_
  9. #include <sys/socket.h>
  10. #endif
  11.  
  12. #ifndef _SYS_TIME_H_
  13. #include <sys/time.h>
  14. #endif
  15.  
  16.  
  17. #define    IFF_UP        0x1        /* interface is up */
  18. #define    IFF_BROADCAST    0x2        /* broadcast address valid */
  19. #define    IFF_DEBUG    0x4        /* turn on debugging */
  20. #define    IFF_LOOPBACK    0x8        /* is a loopback net */
  21. #define    IFF_POINTOPOINT    0x10        /* interface is point-to-point link */
  22. #define    IFF_NOTRAILERS    0x20        /* avoid use of trailers */
  23. #define    IFF_RUNNING    0x40        /* resources allocated */
  24. #define    IFF_NOARP    0x80        /* no address resolution protocol */
  25. #define    IFF_PROMISC    0x100        /* receive all packets */
  26. #define    IFF_ALLMULTI    0x200        /* receive all multicast packets */
  27. #define    IFF_OACTIVE    0x400        /* transmission in progress */
  28. #define    IFF_SIMPLEX    0x800        /* can't hear own transmissions */
  29. #define    IFF_LINK0    0x1000        /* per link layer defined bit */
  30. #define    IFF_LINK1    0x2000        /* per link layer defined bit */
  31. #define    IFF_LINK2    0x4000        /* per link layer defined bit */
  32. #define    IFF_MULTICAST    0x8000        /* supports multicast */
  33.  
  34. /* flags set internally only: */
  35. #define    IFF_CANTCHANGE \
  36.     (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
  37.         IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
  38.  
  39.  
  40. struct    if_data {
  41. /* generic interface information */
  42.     u_char    ifi_type;    /* ethernet, tokenring, etc */
  43.     u_char    ifi_addrlen;    /* media address length */
  44.     u_char    ifi_hdrlen;    /* media header length */
  45.     u_char  ifi_pad1;   /* force natural alignment */
  46.     u_long    ifi_mtu;    /* maximum transmission unit */
  47.     u_long    ifi_metric;    /* routing metric (external only) */
  48.     u_long    ifi_baudrate;    /* linespeed */
  49. /* volatile statistics */
  50.     u_long    ifi_ipackets;    /* packets received on interface */
  51.     u_long    ifi_ierrors;    /* input errors on interface */
  52.     u_long    ifi_opackets;    /* packets sent on interface */
  53.     u_long    ifi_oerrors;    /* output errors on interface */
  54.     u_long    ifi_collisions;    /* collisions on csma interfaces */
  55.     u_long    ifi_ibytes;    /* total number of octets received */
  56.     u_long    ifi_obytes;    /* total number of octets sent */
  57.     u_long    ifi_imcasts;    /* packets received via multicast */
  58.     u_long    ifi_omcasts;    /* packets sent via multicast */
  59.     u_long    ifi_iqdrops;    /* dropped on input, this interface */
  60.     u_long    ifi_noproto;    /* destined for unsupported protocol */
  61.     struct    timeval ifi_lastchange;/* last updated */
  62. };
  63.  
  64. /*
  65.  * The ifaddr structure contains information about one address
  66.  * of an interface.  They are maintained by the different address families,
  67.  * are allocated and attached when an address is set, and are linked
  68.  * together so all addresses for an interface can be located.
  69.  */
  70. struct ifaddr {
  71.     struct    sockaddr *ifa_addr;    /* address of interface */
  72.     struct    sockaddr *ifa_dstaddr;    /* other end of p-to-p link */
  73. #define    ifa_broadaddr    ifa_dstaddr    /* broadcast address interface */
  74.     struct    sockaddr *ifa_netmask;    /* used to determine subnet */
  75.     struct    ifnet *ifa_ifp;        /* back-pointer to interface */
  76.     struct    ifaddr *ifa_next;    /* next address for interface */
  77.     void (*ifa_rtrequest)(long,struct rtentry *,struct sockaddr *);
  78.     u_short    ifa_flags;        /* mostly rt_flags for cloning */
  79.     short    ifa_refcnt;        /* extra to malloc for link info */
  80.     long ifa_metric;        /* cost of going out this interface */
  81. };
  82. #define    IFA_ROUTE    RTF_UP        /* route installed */
  83.  
  84. /*
  85.  * Message format for use in obtaining information about interfaces
  86.  * from getkerninfo and the routing socket
  87.  */
  88. struct if_msghdr {
  89.     u_short    ifm_msglen;    /* to skip over non-understood messages */
  90.     u_char    ifm_version;    /* future binary compatability */
  91.     u_char    ifm_type;    /* message type */
  92.     long    ifm_addrs;    /* like rtm_addrs */
  93.     long    ifm_flags;    /* value of if_flags */
  94.     u_short    ifm_index;    /* index for associated ifp */
  95.     u_short    ifm_pad1;    /* force natural alignment */
  96.     struct    if_data ifm_data;/* statistics and other data about if */
  97. };
  98.  
  99. /*
  100.  * Message format for use in obtaining information about interface addresses
  101.  * from getkerninfo and the routing socket
  102.  */
  103. struct ifa_msghdr {
  104.     u_short    ifam_msglen;    /* to skip over non-understood messages */
  105.     u_char    ifam_version;    /* future binary compatability */
  106.     u_char    ifam_type;    /* message type */
  107.     long    ifam_addrs;    /* like rtm_addrs */
  108.     long    ifam_flags;    /* value of ifa_flags */
  109.     u_short    ifam_index;    /* index for associated ifp */
  110.     u_short    ifam_pad1;    /* force natural alignment */
  111.     long    ifam_metric;    /* value of ifa_metric */
  112. };
  113.  
  114. /*
  115.  * Interface request structure used for socket
  116.  * ioctl's.  All interface ioctl's must have parameter
  117.  * definitions which begin with ifr_name.  The
  118.  * remainder may be interface specific.
  119.  */
  120. struct    ifreq {
  121. #define    IFNAMSIZ    16
  122.     char    ifr_name[IFNAMSIZ];        /* if name, e.g. "en0" */
  123.     union {
  124.         struct    sockaddr ifru_addr;
  125.         struct    sockaddr ifru_dstaddr;
  126.         struct    sockaddr ifru_broadaddr;
  127.         short    ifru_flags;
  128.         long    ifru_metric;
  129.         long    ifru_mtu;
  130.         long    ifru_phys;
  131.         caddr_t    ifru_data;
  132.     } ifr_ifru;
  133. #define    ifr_addr    ifr_ifru.ifru_addr    /* address */
  134. #define    ifr_dstaddr    ifr_ifru.ifru_dstaddr    /* other end of p-to-p link */
  135. #define    ifr_broadaddr    ifr_ifru.ifru_broadaddr    /* broadcast address */
  136. #define    ifr_flags    ifr_ifru.ifru_flags    /* flags */
  137. #define    ifr_metric    ifr_ifru.ifru_metric    /* metric */
  138. #define    ifr_mtu        ifr_ifru.ifru_mtu    /* mtu */
  139. #define ifr_phys    ifr_ifru.ifru_phys    /* physical wire */
  140. #define    ifr_data    ifr_ifru.ifru_data    /* for use by interface */
  141. };
  142.  
  143. struct ifaliasreq {
  144.     char    ifra_name[IFNAMSIZ];        /* if name, e.g. "en0" */
  145.     struct    sockaddr ifra_addr;
  146.     struct    sockaddr ifra_broadaddr;
  147.     struct    sockaddr ifra_mask;
  148. };
  149.  
  150. /*
  151.  * Structure used in SIOCGIFCONF request.
  152.  * Used to retrieve interface configuration
  153.  * for machine (useful for programs which
  154.  * must know all networks accessible).
  155.  */
  156. struct    ifconf {
  157.     long    ifc_len;        /* size of associated buffer */
  158.     union {
  159.         caddr_t    ifcu_buf;
  160.         struct    ifreq *ifcu_req;
  161.     } ifc_ifcu;
  162. #define    ifc_buf    ifc_ifcu.ifcu_buf    /* buffer address */
  163. #define    ifc_req    ifc_ifcu.ifcu_req    /* array of structures returned */
  164. };
  165.  
  166. struct if_nameindex {
  167.     unsigned long    if_index;
  168.     char             *if_name;
  169. };
  170.  
  171. #endif /* !_NET_IF_H_ */
  172.